package com.graduationproject.examonline.scorePaper.controller;

import com.graduationproject.examonline.scorePaper.service.ScorePaperService;
import com.graduationproject.examonline.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/api/scorePaper")
public class ScorePaperController {
    @Autowired
    private ScorePaperService scorePaperService;

    @PostMapping("/submitAnswer")
    public Result submitAnswer(@RequestBody Map<String, Object> data) {
        return scorePaperService.submitAnswer((Map<String, Object>) data.get("score_paper"), (Map<String, Object>) data.get("answer_paper"));
    }

    @GetMapping("/getScoreInfoByStuIdAndExamId")
    public Result getScoreInfoByStuIdAndExamId(String stu_id, String exam_id) {
        return scorePaperService.getScoreInfoByStuIdAndExamId(stu_id, exam_id);
    }

    @GetMapping("/getStuAnswerByExamId")
    public Result getStuAnswerByExamId(String stu_id, String exam_id) {
        return scorePaperService.getStuAnswerByExamId(stu_id, exam_id);
    }

    @GetMapping("/getScoreByExamId")
    public Result getScoreByExamId(String exam_id){
        return scorePaperService.getScoreByExamId(exam_id);
    }
}
